//
//  main.cpp
//  数据结构
//
//  Created by linjinzhu on 2017/7/11.
//  Copyright © 2017年 baidu. All rights reserved.
//

#include <iostream>

using namespace std;

// 定义结构体，方式一
struct Book {
    char title[100];
    int  id;
};

// 定义结构体，方式二
typedef struct {
    char name[100];
    int  id;
} Car;


void printStruct(struct Book book);
void printStruct2(struct Book *book);

int main(int argc, const char * argv[]) {

    struct Book b1;
    struct Book b2;

    strcpy(b1.title, "C++ primer");
    b1.id = 1;

    strcpy(b2.title, "C primer");
    b2.id = 2;

    printStruct(b1);
    printStruct(b2);

    printStruct2(&b1);
    printStruct2(&b2);

    return 0;
}

void printStruct(struct Book book) {
    cout << &book << endl;
    cout << book.title << endl;
    cout << book.id << endl;
}

void printStruct2(struct Book *book) {
    cout << &book << endl;
    cout << book->title << endl;
    cout << book->id << endl;
}
